package com.jingdianjichi.auth.domain.service.impl;


import com.jingdianjichi.auth.common.enums.IsDeletedFlagEnum;
import com.jingdianjichi.auth.domain.convert.AuthBOConverter;
import com.jingdianjichi.auth.domain.entity.AuthRoleBO;
import com.jingdianjichi.auth.domain.service.AuthRoleDomainService;
import com.jingdianjichi.auth.infra.basic.entity.AuthRole;
import com.jingdianjichi.auth.infra.basic.service.AuthRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AuthRoleDomainServiceImpl implements AuthRoleDomainService {

    @Resource
    private AuthRoleService authRoleService;

    /**
     * 新增角色
     */
    @Override
    public Boolean add(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthBOConverter.INSTANCE.convertAuthRoleBOToEntity(authRoleBO);
        authRole.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        Integer count=authRoleService.insert(authRole);
        return count>0;
    }
    /**
     * 修改角色
     */
    @Override
    public Object update(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthBOConverter.INSTANCE.convertAuthRoleBOToEntity(authRoleBO);
        Integer count=authRoleService.update(authRole);
        return count>0;
    }
    /**
     * 删除角色
     */
    @Override
    public Object delete(AuthRoleBO authRoleBO) {
        AuthRole authRole = new AuthRole();
        authRole.setId(authRoleBO.getId());
        authRole.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        Integer count=authRoleService.update(authRole);
        return count>0;
    }
}
